package main

import (
	"fmt"
	"unsafe"
)

type A struct {
	ID int
}

type B struct {
	A
	ID int
}

func main() {
	fmt.Println(unsafe.Sizeof(A{})) //8
	fmt.Println(unsafe.Sizeof(B{})) //16

	//嵌套的初始化，必须指定Key
	b := B{A: A{ID: 1}, ID: 2}
	fmt.Println(b)
	fmt.Println(b.ID)
	b.ID++
	fmt.Println(b)
	fmt.Println(b.ID)
	b.A.ID++
	fmt.Println(b)
	fmt.Println(b.ID)

	fmt.Println("------------")
	b.A.Go()
	b.Go()
}

func (a *A) Go() {
	fmt.Println("A.Go", a.ID)
}
func (b *B) Go() {
	fmt.Println("B.Go", b.ID)
}
